<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="<%=basePath%>/static/js/jquery-3.3.1.js"></script>
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>/static/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>/static/css/basic.css">
<script src="<%=basePath%>/static/js/bootstrap.min.js"></script>
<style>
.bootstrap-admin-panel-content {
	padding-top: 10px;
}

.black_overlay {
	display: none;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.3);
	z-index: 1001;
	filter: alpha(opacity = 88);
}

.white_content {
	display: none;
	position: absolute;
	top: 8%;
	left: 25%;
	width: 50%;
	height: auto;
	padding: 20px;
	border: 1px solid gray;
	background-color: white;
	z-index: 1002;
	overflow: auto;
	border-radius: 8px;
}

.btn-sm {
	margin-left: 30px;
}

textarea {
	resize: none;
}
</style>
<script>
	$(function() {
		$(".add-book").on("click", function() {
			$("#light").hide().fadeIn(600).css("display", "block");
			$("#fade").hide().fadeIn(600).css("display", "block");
		});

		$(".closeBtn").on("click", function() {
			$("#light").fadeOut(600).hide(300);
			$("#light-up").fadeOut(600).hide(300);
			$("#fade").fadeOut(600).hide(300);
			$("#light-watch").fadeOut(600).hide(300);
			$("#light-update").fadeOut(600).hide(300);
			$("#light-import-excel").fadeOut(600).hide(300);
		});

		/*每一个书籍的查看按钮的注册点击事件*/
		$(".btn-watch").on("click", function() {

			let parent = $(this).parent().parent();
			// let bookId = parent.find(".bookId").text();
			// alert(bookId);
			$("#lessonId-wt").val(parent.find(".lessonId").text());
			$("#lessonType-wt").val(parent.find(".lessonType").text());
			$("#lessonName-wt").val(parent.find(".lessonName").text());

			$("#light-watch").hide().fadeIn(600).css("display", "block");
			$("#fade").hide().fadeIn(600).css("display", "block");
		})

		$(".btn-update").on("click", function() {

			let parent = $(this).parent().parent();
			$("#lessonId-up").val(parent.find(".lessonId").text());
			$("#lessonType-up").val(parent.find(".lessonType").text());
			$("#lessonName-up").val(parent.find(".lessonName").text());

			$("#light-update").hide().fadeIn(600).css("display", "block");
			$("#fade").hide().fadeIn(600).css("display", "block");
		});

		$(".add-books").on(
				"click",
				function() {

					$("#light-import-excel").hide().fadeIn(600).css("display",
							"block");
					$("#fade").hide().fadeIn(600).css("display", "block");
				});

	})
</script>
</head>
<body>
	<!--头部-->
	<nav class="navbar navbar-inverse navbar-fixed-top">
		<div class="container-fluid">
			<!-- Brand and toggle get grouped for better mobile display -->
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed"
					data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"
					aria-expanded="false">
					<span class="sr-only">Toggle navigation</span> <span
						class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="<%=path%>/admin/admin">欢迎来到图书管理系统</a>
			</div>

			<!-- Collect the nav links, forms, and other content for toggling -->
			<div class="collapse navbar-collapse"
				id="bs-example-navbar-collapse-1">
				<ul class="nav navbar-nav navbar-right">
					<!--<li><a href="javascript:;" class="btn btn-default btn-login">登录</a></li>-->
					<li class="dropdown" style="margin-top: 5px;"><a href="#"
						class="dropdown-toggle" data-toggle="dropdown" role="button"
						aria-haspopup="true" aria-expanded="false"> <span
							class="glyphicon glyphicon-user"></span> 欢迎您， admin <span
							class="caret"></span></a>
						<ul class="dropdown-menu" style="margin-top: 2px">
							<li><a href="#">Action</a></li>
							<li><a href="#">Another action</a></li>
							<li><a href="#">Something else here</a></li>
							<li role="separator" class="divider"></li>
							<li><a href="#">Separated link</a></li>
						</ul></li>
				</ul>
			</div>
			<!-- /.navbar-collapse -->
		</div>
		<!-- /.container-fluid -->
	</nav>

	<!--主体-->
	<div class="container-fluid" id="main">
		<div class="row">
			<div class="col-md-3 left-content">
				<div class="aside-nav">
					<ul class="list-group aside-nav-list">
						<li class="list-group-item "><a
							href="<%=path%>/questions/admin/selectQuestion">试题信息管理 <span
								class="pull-right glyphicon glyphicon-chevron-right"></span>
						</a></li>
						<li class="list-group-item active"><a
							href="<%=path%>/lesson/admin/selectLesson">课程管理 <span
								class="pull-right glyphicon glyphicon-chevron-right"></span>
						</a></li>
						<li class="list-group-item "><a
							href="<%=path%>/results/admin/selectResults">成绩查询 <span
								class="pull-right glyphicon glyphicon-chevron-right"></span>
						</a></li>

						<!--<li class="list-group-item">Dapibus ac facilisis in</li>-->
						<!--<li class="list-group-item">Morbi leo risus</li>-->
						<!--<li class="list-group-item">Porta ac consectetur ac</li>-->
						<!--<li class="list-group-item">Vestibulum at eros</li>-->
					</ul>
				</div>
			</div>
			<div class="col-md-9 right-content">
				<div class="section-wrap">
					<div class="wrap-top">
						<div class="panel panel-default">
							<div class="panel-heading">课程管理</div>
							<div class="panel-body">

								<form class="form-horizontal"
									action="<%=path%>/lesson/admin/selectLessonInfo" method="post">

									<div class="form-group col-md-6">
										<label for="typeName"
											class="col-sm-3 control-label text-right">课程类型</label>
										<div class="col-sm-9">
											<select class="form-control" id="lessonType"
												name="lessonType">
												<c:forEach items="${lessonTypes}" var="Type">
													<option value=${Type }>${Type }</option>
												</c:forEach>
											</select>
										</div>
									</div>

									<div class="form-group col-md-6">
										<label for="bookName"
											class="col-sm-3 control-label text-right">课程Id</label>
										<div class="col-sm-9">
											<input type="text" class="form-control" id="lessonId"
												name="lessonId" placeholder="lessonId">
										</div>
									</div>

									<div class="form-group col-md-6">
										<label for="bookName"
											class="col-sm-3 control-label text-right">课程名称</label>
										<div class="col-sm-9">
											<input type="text" class="form-control" id="lessonName"
												name="lessonName" placeholder="lessonName">
										</div>
									</div>

									<div
										class="form-group col-md-3 col-xs-3 col-xs-offset-3 last-form-group">
										<button class="btn btn-default btn-primary" type="submit">查询</button>
										<input type="button" class="btn btn-info btn-sm add-book"
											value="添加课程" />
									</div>

								</form>
							</div>
						</div>
					</div>
					<div class="wrap-bottom">
						<table class="table table-bordered">
							<thead>
								<tr>
									<th class="lessonId">课程编号</th>
									<th class="lessonType">课程类型</th>
									<th class="lessonName">课程名称</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach var="lessons" items="${lessonList}">
									<tr>
										<td class="lessonId">${lessons.lessonId}</td>
										<td class="lessonType">${lessons.lessonType}</td>
										<td class="lessonName">${lessons.lessonName}</td>
										<td>
											<button class="btn btn-xs btn-success btn-update"
												style="margin-right: 3px">修改</button> 
											<a
											class="btn btn-xs btn-danger btn-del"
											style="margin-right: 3px"
											href="<%=basePath%>/lesson/del/${lessons.lessonId}">删除</a>
										</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
					</div>

				</div>
			</div>
		</div>
	</div>
	<%--添加按钮的弹出框--%>
	<div id="light" class="white_content">
		<button type="button" class="close closeBtn" data-dismiss="modal"
			aria-label="Close">
			<span aria-hidden="true">×</span>
		</button>
		<div class="row">
			<div class="col-md-10 col-sm-offset-1">
				<!--保证样式水平不混乱-->
				<form class="form-horizontal" method="post"
					action="<%=basePath%>/lesson/add">
					<div class="modal-header">
						<h4 class="modal-title" id="myModalLabel">添加试题</h4>
					</div>
					<div class="modal-body">
						<!---------------------表单-------------------->

						<div class="form-group">
							<label for="author-add" class="col-sm-3 control-label">课程分类</label>
							<div class="col-sm-7">
								<input type="text" class="form-control" id="lessonType-add"
									name="lessonType">
							</div>
						</div>

						<div class="form-group">
							<label for="author-add" class="col-sm-3 control-label">课程名</label>
							<div class="col-sm-7">
								<input type="text" class="form-control" id="lessonName-add"
									name="lessonName">
							</div>
						</div>
						
						<!---------------------表单-------------------->
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default closeBtn"
							data-dismiss="modal">关闭</button>
						<button type="submit" class="btn btn-primary" id="addReaderType">
							添加</button>
					</div>
				</form>
			</div>
		</div>
	</div>
	<%--弹出层的半透明背景--%>
	<div id="fade" class="modal black_overlay"></div>
<%--修改试题的弹出框--%>
	<div id="light-update" class="white_content">
		<button type="button" class="close closeBtn" data-dismiss="modal"
			aria-label="Close">
			<span aria-hidden="true">×</span>
		</button>
		<div class="row">
			<div class="col-md-10 col-sm-offset-1">
				<!--保证样式水平不混乱-->
				<form class="form-horizontal" method="post"
					action="<%=basePath%>/lesson/update">
					<div class="modal-header">
						<h4 class="modal-title" id="myModalLabel-update">修改试题详情</h4>
					</div>
					<div class="modal-body">
						<!---------------------表单-------------------->
						<div class="form-group hidden">
							<label for="author-add" class="col-sm-3 control-label">课程Id</label>
							<div class="col-sm-7">
								<input type="text" class="form-control" id="lessonId-up"
									name="lessonId">
							</div>
						</div>
						<div class="form-group">
							<label for="author-add" class="col-sm-3 control-label">课程分类</label>
							<div class="col-sm-7">
								<input type="text" class="form-control" id="lessonType-up"
									name="lessonType">
							</div>
						</div>
						<div class="form-group">
							<label for="author-add" class="col-sm-3 control-label">课程名</label>
							<div class="col-sm-7">
								<input type="text" class="form-control" id="lessonName-up"
									name="lessonName">
							</div>
						</div>
						
						<!---------------------表单-------------------->
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default closeBtn"
							data-dismiss="modal">关闭</button>
						<button type="submit" class="btn btn-primary" id="updataBook">
							更新</button>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
</html>